﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace SME.Food.Surperise.BLL
{
   public class Common
    {
        /// <summary>
        /// 错误成功消息固定
        /// </summary>
        /// <param name="isRight">true：返回成功，false：返回失败</param>
        /// <param name="closeCurrent">true：成功之后关闭当前窗口</param>
        /// <param name="navTabId">目标页面ID</param>
        /// <param name="rel">目标页面ID</param>
        /// <param name="forwardUrl">成功之后需要刷新的页面</param>
        public static void DwzMessage(bool isRight, bool closeCurrent, string navTabId, string rel, string forwardUrl)
        {
            if (isRight == false)
            {
                HttpContext.Current.Response.Write("{\"statusCode\":\"300\", \"message\":\"操作失败\"," +
                                                   " \"navTabId\":\"\", \"rel\":\"\",\"callbackType\":" +
                                                   "\"\",\"forwardUrl\":\"\"}");
            }
            else
            {
                string close = closeCurrent ? "closeCurrent" : "";
                HttpContext.Current.Response.Write("{\"statusCode\":\"200\", \"message\":\"操作成功\"," +
                                                   " \"navTabId\":\"" + navTabId + "\", \"rel\":\"" + rel +
                                                   "\",\"callbackType\":" +
                                                   "\"" + close + "\",\"forwardUrl\":\"" + forwardUrl + "\"}");
            }
        }
    }
}
